/*
 * @Author: 大辉 dbstt@qq.com
 * @Date: 2023-05-06 17:03:02
 * @LastEditors: 大辉 dbstt@qq.com
 * @LastEditTime: 2023-05-06 18:19:53
 * @FilePath: /intelligentQuery/src/redux/siteConfig.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { createSlice } from '@reduxjs/toolkit';

export const counterSlice = createSlice({
  name: 'siteConfig',
  initialState: {
    menuPosition: 'left',
    colorModel: 'default'
  },
  reducers: {
    increment: (state) => {
      // Redux Toolkit 允许我们在 reducers 中编写 mutating 逻辑。
      // 它实际上并没有 mutate state 因为它使用了 Immer 库，
      // 它检测到草稿 state 的变化并产生一个全新的基于这些更改的不可变 state
      state.value += 1;
    },
    setMenuPosition: (state, {payload}) => {
      state.menuPosition = payload
    },
    setColorModel: (state, {payload}) => {
      state.colorModel = payload
    },
    incrementByAmount: (state, action) => {
      state.value += action.payload;
    },
  },
});

// 为每个 case reducer 函数生成 Action creators
export const { setMenuPosition,setColorModel } = counterSlice.actions;

export default counterSlice.reducer;